home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Apple Reference & Presen…tion Library 2 (Reseller)
/
Apple R&P Lib Reseller v2.0.iso
/
3-Demos
/
HyperCard Demos
/
HyperMovies
/
CL⁄1
/
CL_1
/
background_3788.txt
< prev
next >
Wrap
Text File
|
1989-10-27
|
12KB
|
466 lines
-- background: 3788 from stack: in
-- bmap block id: 8808
-- flags: 4000
-- background id: 0
-- name: Sales Rep Cards
----- HyperTalk script -----
on openCard
global quotaHasChanged
if inDebug() then pass openCard
set lockscreen to true
put word 2 of the short name of this card into repNum
get repInfo(repNum)
put line 1 of it into regionNum
put line 2 of it into quota
put line 3 of it into sales
put 100*sales/quota into percent
put repNum into line 4 of field "Sales Rep Data"
put regionNum into line 5 of field "Sales Rep Data"
set name of card button 1 to addComma(quota) & " >>"
put addComma(sales) into field "Rep Sales"
put formatPercent(percent) into card field "Percent of Quota"
get char 1 to 3 of quota
put 306 - it into height
get the loc of card button 1
put height into item 2 of it
set loc of card button 1 to it
AdjustQuotaBkgnd height
RedrawRepChart percent
set lockscreen to false
put false into quotaHasChanged
hide field "Status Backdrop"
hide field "Status"
pass openCard
end openCard
on closeCard
global QuotaHasChanged
if inDebug() then pass closeCard
if QuotaHasChanged then
if UpdateRealFigures () then
--update the corresponding bar in the region chart
global updateThisBar
put word 2 of short name of this card into updateThisBar
end if
put false into QuotaHasChanged
end if
put empty into field "Status"
hide field "Status Backdrop"
hide field "Status"
pass closeCard
end closeCard
on RedrawRepChart percent
set lockScreen to true
put the rect of bkgnd button "Rep Quota" into area
choose select tool
drag from item 1 of area,0 to item 3 to 4 of area
doMenu "Clear Picture"
set lockScreen to false
DrawLargeBar area,percent
put formatPercent (percent) into card field "Percent of Quota"
choose browse tool
end RedrawRepChart
on movePointer
global nuQuota, quotaHasChanged
put the loc of the target into myLoc
get the mouseV
repeat until the mouse is up
get the mouseV
put it into item 2 of myLoc
set the loc of the target to myLoc
put 306 - it into nuQuota
put "000.00" after nuQuota
set the name of the target to addComma (nuQuota) & " >>"
end repeat
AdjustQuotaBkgnd it
put true into quotaHasChanged
RedoLocalFigures
end movePointer
-- This is called by the button that adjusts the quota
on RedoLocalFigures
global nuQuota
put dataCardName() into cardName
put word 2 of short name of this card into repNum
put itemOffset(repNum,field "rep_nr" of card cardName) into itemNum
get item itemNum of field "sales" of card cardName
put formatPercent (100*it/nuQuota) into percent
put percent into card field "Percent of Quota"
end RedoLocalFigures
-- This is called on closeCard if the QuotaHasChanged
function UpdateRealFigures
global nuQuota, ChangedList, QuotaHasChanged
put DataCardName() into cardName
put SalesRepNum() into repNum
put itemOffset(repNum,field "rep_nr" of card cardName) into itemNum
--put field "Item Offset" into itemNum
put addComma (nuQuota) into quota
answer "Change the quota to" && quota & "?" with "No" or "OK"
set cursor to 4
if it is "OK" then
show field "Status Backdrop"
show field "Status"
put "Updating record..." into field "Status"
-- Change the quota for this rep in the staff table
put field "quota" of card cardName into regionQuotas
put nuQuota into item itemNum of regionQuotas
put regionQuotas into field "quota" of card cardName
put card field "Percent of Quota" into percent
put empty into last char of percent
put percent into item itemNum of field "percent" of card cardName
put "SendSalesRepData" && repNum & "," && nuQuota & "," && quote & cardName & quote into theMessage
send theMessage to card cardName
put empty into field "Status"
wait 45 ticks
put "Update completed" into field "Status"
-- Change the regional quota in the all-region data card
put RegionNum() into region
put 0 into total
repeat with i = 1 to the number of items in regionQuotas
add item i of regionQuotas to total
end repeat
put field "quota" of card "All Regions" into allQuotas
put itemOffset (region, AllRegionNums()) into i
put addDecimal (total) into total
put total into item i of allQuotas
put allQuotas into field "quota" of card "All Regions"
put item i of field "sales" of card "All Regions" into sales
put formatPercent(sales/total*100) into percent
put empty into last char of percent
put percent into item i of field "percent" of card "All Regions"
-- Change the regional quota in the offices table in host database
put "SendRegionData" && region & "," && total into theMessage
send theMessage to card "All Regions"
hide field "Status Backdrop"
hide field "Status"
return true
else
-- retrieve quota & percent from dataCard
-- restore fields & graph on this card
put item itemNum of field "quota" of card cardName into quota
get char 1 to 3 of quota
put 306 - it into nuHeight
AdjustQuotaBkgnd nuHeight
get loc of card button 1
put nuHeight into item 2 of it
set loc of card button 1 to it
set name of card button 1 to addComma (quota) & " >>"
put item itemNum of field "percent" of card cardName into percent
RedrawRepChart percent
put false into QuotaHasChanged
return false
end if
end UpdateRealFigures
function SalesRepNum
return word 2 of the short name of this card
end SalesRepNum
function RegionNum
get SalesRepNum()
return line 5 of field "Sales Rep Data"
end RegionNum
function DataCardName
return "Region" && RegionNum()
end DataCardName
function ChartCardName
return "Region" && RegionNum() && "Chart"
end ChartCardName
on AdjustQuotaBkgnd nuHeight
set cursor to 4
set lockScreen to true
get the rect of bkgnd btn "Rep Quota"
put nuHeight into item 2 of it
set the rect of bkgnd btn "Rep Quota" to it
get the rect of bkgnd btn "Rep Quota shadow"
put nuHeight+5 into item 2 of it
set the rect of bkgnd btn "Rep Quota shadow" to it
set lockScreen to false
end AdjustQuotaBkgnd
on xAdjustQuotaBkgnd nuHeight
put 300000 into maxQuota
put 0 into minQuota
set cursor to 4
set lockScreen to true
set editBkgnd to true
get the rect of bkgnd btn "Rep Quota"
put nuHeight into item 2 of it
set the rect of bkgnd btn "Rep Quota" to it
put item 4 of it into bottom
put item 3 of it into left
put item 2 of it into top
choose select tool
drag from left-1, bottom to 512, 0
doMenu "Clear Picture" -- clear right side of screen
choose line tool
set lineSize to 6
drag from left+2, bottom+2 to left+2, top+8 -- redraw the shadow
choose browse tool
set lockScreen to false
end xAdjustQuotaBkgnd
function SalesDataForRep repNum, regionNum
put "Region" && regionNum into cardName
get itemOffset (repNum, field "rep_nr" of card cardName)
put item it of field "sales" of card cardName into data
put item it of field "percent" of card cardName into item 2 of data
put item it of field "quota" of card cardName into item 3 of data
return data
end SalesDataForRep
on openBackground
push recent card
end openBackground
-- part 1 (field)
-- low flags: 01
-- high flags: 2000
-- rect: left=5 top=185 right=268 bottom=80
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 65535
-- font id: 20
-- text size: 12
-- style flags: 0
-- line height: 14
-- part name: Labels
-- part 2 (field)
-- low flags: 01
-- high flags: 2002
-- rect: left=186 top=5 right=52 bottom=393
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 1
-- font id: 20
-- text size: 18
-- style flags: 0
-- line height: 20
-- part name: Title
-- part 23 (field)
-- low flags: 81
-- high flags: 2002
-- rect: left=38 top=11 right=29 bottom=89
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 1
-- font id: 3
-- text size: 9
-- style flags: 256
-- line height: 12
-- part name: item offset
-- part 3 (field)
-- low flags: 01
-- high flags: 2000
-- rect: left=78 top=185 right=268 bottom=271
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 0
-- font id: 20
-- text size: 12
-- style flags: 256
-- line height: 14
-- part name: Sales Rep Data
-- part 28 (button)
-- low flags: 00
-- high flags: 4002
-- rect: left=412 top=186 right=306 bottom=502
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 1
-- font id: 0
-- text size: 12
-- style flags: 0
-- line height: 16
-- part name: Rep Quota shadow
-- part 10 (button)
-- low flags: 00
-- high flags: 0002
-- rect: left=407 top=181 right=301 bottom=497
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 1
-- font id: 0
-- text size: 12
-- style flags: 0
-- line height: 16
-- part name: Rep Quota
-- part 14 (field)
-- low flags: 00
-- high flags: 2000
-- rect: left=409 top=302 right=327 bottom=498
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 1
-- font id: 3
-- text size: 10
-- style flags: 256
-- line height: 15
-- part name: Rep Sales
-- part 15 (field)
-- low flags: 01
-- high flags: 0000
-- rect: left=13 top=273 right=337 bottom=371
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 0
-- font id: 20
-- text size: 12
-- style flags: 0
-- line height: 14
-- part name:
-- part 20 (button)
-- low flags: 00
-- high flags: 4000
-- rect: left=185 top=4 right=53 bottom=395
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 1
-- font id: 0
-- text size: 12
-- style flags: 0
-- line height: 16
-- part name:
----- HyperTalk script -----
on mouseUp
set the hilite of the target to true
visual effect iris close
go to card ChartCardName()
end mouseUp
-- part 21 (button)
-- low flags: 00
-- high flags: 0000
-- rect: left=10 top=5 right=183 bottom=179
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 1
-- font id: 0
-- text size: 12
-- style flags: 0
-- line height: 16
-- part name:
----- HyperTalk script -----
on mouseUp
visual effect iris close
go to card ChartCardName()
end mouseUp
-- part 22 (field)
-- low flags: 01
-- high flags: 2000
-- rect: left=407 top=316 right=337 bottom=501
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 1
-- font id: 3
-- text size: 10
-- style flags: 0
-- line height: 13
-- part name: Sales Label
-- part 24 (field)
-- low flags: 80
-- high flags: 2004
-- rect: left=78 top=206 right=265 bottom=386
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 1
-- font id: 3
-- text size: 12
-- style flags: 256
-- line height: 16
-- part name: Status Backdrop
-- part 25 (field)
-- low flags: 80
-- high flags: 2000
-- rect: left=78 top=222 right=256 bottom=385
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 1
-- font id: 3
-- text size: 12
-- style flags: 256
-- line height: 16
-- part name: Status
-- part 26 (button)
-- low flags: 00
-- high flags: 2000
-- rect: left=183 top=134 right=184 bottom=231
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 1
-- font id: 0
-- text size: 12
-- style flags: 0
-- line height: 16
-- part name: Region Chart
----- HyperTalk script -----
on mouseUp
visual effect iris close
go to card ChartCardName()
end mouseUp
on xmouseUp
global QuotaHasChanged
visual effect iris close
put line 5 of field "Sales Rep Data" into regionNum
if QuotaHasChanged then
put UpdateRealFigures () into PermanentChange
go to card "Region" && regionNum && "Chart"
if PermanentChange then DoGraph
put false into QuotaHasChanged
else
go to card "Region" && regionNum && "Chart"
end if
end xmouseUp